﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NightWolf.Sonar;

namespace Nuzzle.Database.Models
{
    [SonarTable("accounts")]
    public class AccountModel : SonarRecord
    {
        [SonarField("ID", true)]
        public int ID;

        [SonarField("Username")]
        public string Username;

        [SonarField("Password")]
        public string Password;

        [SonarField("Pseudo")]
        public string Pseudo;

        [SonarField("Email")]
        public string Email;

        [SonarField("OpLevel")]
        public int OpLevel;

        [SonarField("Banned")]
        public int Banned;

        public List<CharacterModel> Characters = new List<CharacterModel>();

        public Database.Models.CharacterModel GetCharacter(int id)
        {
            if (Characters.FindAll(x => x.ID == id).Count > 0)
            {
                return Characters.FirstOrDefault(x => x.ID == id);
            }
            else
            {
                return null;
            }
        }
    }
}
